goog.provide('secureSites.SecureProber');

goog.require('secureSites');
goog.require('secureSites.TriState');
goog.require('secureSites.constants');

secureSites.SecureProber = function() {
//Hook in to HTTPS requests to monitor extension-triggered requests
//  chrome.experimental.webRequest.onBeforeRequest.addListener(
//    function(details) { console.log("onBeforeRequest: " + JSON.stringify(details)); }, secureSites.constants.EXTENSION_BASED_HTTPS_ONLY_REQUEST_FILTER);
//  chrome.experimental.webRequest.onResponseStarted.addListener(
//    function(details) { self.onHeadersReceivedHandler(details); });
};

/**
 * Indicates whether a secure version exists for a passed url.
 * Uses a cache, and assumes any OK returned content is correct content,
 * so may not be 100% accurate - should have a manual override option over
 * any result.
 * @param {!string} url
 * @return {!boolean} Whether a secure version exists
  */
secureSites.SecureProber.prototype.secureVersionExistsFor = function(url) {
  //TODO: Probe properly
  //this.probe(url, function() {});
  return secureSites.TriState.TRUE;
};

/*secureSites.SecureProber.prototype.probe = function(url, callback) {
  console.log('Probing: ' + url);
  var xhr = new XMLHttpRequest();
  xhr.onreadystatechange = function() {
    if (this.readyState == 4) {
      callback({url: url, statusCode: this.status});
    }
  };
  xhr.open('HEAD', secureSites.secureVersionOf(url), true);
  xhr.send('');
};*/